package com.yesorno.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yesorno.constants.Constants;
import com.yesorno.ui.CustomTitleActivity;

public class FindPwdActivity extends CustomTitleActivity {

	private Button goBack;

	private Button genderpwd;
	private Button regenderpwd;

	private LinearLayout find_pwd_state_common;
	private LinearLayout find_pwd_state_gone;

	private TextView find_pwd_alert;

	RegBtnsClickListeners rbc = new RegBtnsClickListeners();

	/**
	 * 注册页面按钮的监听类
	 * 
	 * @author samoin
	 * @date 2011-07-06
	 * @version 0.1
	 * 
	 */
	class RegBtnsClickListeners implements OnClickListener {
		@Override
		public void onClick(View v) {
			if (v == goBack) {
				Intent intent = new Intent();
				intent.putExtra("test", "waitActive");
				FindPwdActivity.this.setResult(RESULT_OK, intent);
				FindPwdActivity.this.finish();
			}
			if (v == genderpwd) {
				// TODO 发送请求，进行返回操作
				find_pwd_state_common.setVisibility(View.GONE);
				find_pwd_state_gone.setVisibility(View.VISIBLE);
			}
			if (v == regenderpwd) {
				// TODO 再次发送并返回，须判断是否已经发送了3次

				boolean flag = true;
				if (flag) {
					find_pwd_alert.setVisibility(View.VISIBLE);
					regenderpwd
							.setText(R.string.find_pwd_btn_regenderpwdtomuch);
					regenderpwd.setTextColor(getResources().getColor(
							R.color.btn_disabled_color));
				}
			}
		}

	}

	@Override
	public void setTitleViews() {
		LinearLayout titleLayout = getTITLE_LAYOUT();
		goBack = CustomTitleActivity.createTitleLeftButton(FindPwdActivity.this,
				R.string.reg_title_btn_goback, Constants.TITLE_BTN_MARGIN1);
		goBack.setOnClickListener(rbc);
		titleLayout.addView((View) goBack.getParent());
		TextView tv = CustomTitleActivity.createTitleDesc(FindPwdActivity.this,
				R.string.wait_active_title_common, 0);
		titleLayout.addView((View) tv.getParent());
		titleLayout.addView((View) CustomTitleActivity.createTitleDesc(
				FindPwdActivity.this, 0, 0).getParent());

		genderpwd = (Button) findViewById(R.id.find_pwd_btn_genderpwd);
		genderpwd.setOnClickListener(rbc);
		genderpwd.getPaint().setFakeBoldText(true);
		regenderpwd = (Button) findViewById(R.id.find_pwd_btn_regenderpwd);
		regenderpwd.setOnClickListener(rbc);
		regenderpwd.getPaint().setFakeBoldText(true);

		find_pwd_alert = (TextView) findViewById(R.id.find_pwd_alert);

		find_pwd_state_common = (LinearLayout) findViewById(R.id.find_pwd_state_common);
		find_pwd_state_gone = (LinearLayout) findViewById(R.id.find_pwd_state_gone);

	}

	@Override
	public void setLayoutId() {
		setContentView(R.layout.find_pwd);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

}
